package com.example.cardserver.service.impl;

import com.example.cardserver.entity.SocNews;
import com.example.cardserver.mapper.SocNewsMapper;
import com.example.cardserver.service.ISocNewsService;
import com.example.cardserver.service.ex.SocNewsException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SocNewsServiceImpl implements ISocNewsService {
    @Resource
    private SocNewsMapper socNewsMapper;
    
    @Override
    public List<SocNews> listAllNews() {
        List<SocNews> list = socNewsMapper.findList();
        return list;
    }

    @Override
    public SocNews findById(Integer id) {
        SocNews news = socNewsMapper.findById(id);
        if(news == null){
            throw new SocNewsException("数据不存在");
        }
        return news;
    }
}
